﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Enterprise.Framework.Frame.Architecture;
using Resto.CostControl.Core.Domain.Model;
using Enterprise.Framework.Core.Exceptions;
using Enterprise.Framework.DomainModel.Repositories;

namespace Resto.CostControl.Core.Domain.Query.SupplierModule
{
    internal class MaterialPurchaseDQO : IDomainQueryObject
    {
        public MaterialPurchase GetMaterialPurchase(string id)
        {
            MaterialPurchase order = GetMaterialPurchaseOrDefault(id);

            if (order == null)
                throw new BusinessException("指定Id的原材料采购单不存在");

            return order;
        }

        public MaterialPurchase GetMaterialPurchaseOrDefault(string id)
        {
            IEntityRepository<MaterialPurchase> repository = RestoCostDomainSession.CurrentSession.CreateEntityRepository<MaterialPurchase>();
            MaterialPurchase order = repository.Objects.Where(p => p.ID == id).FirstOrDefault();

            return order;
        }



    }
}
